package org.makeprogress.springbootbase.delegate;

import org.makeprogress.springbootbase.domain.test.ITestService;
import org.makeprogress.springbootbase.model.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.stream.IntStream;

/**
 * @author liuyi
 * @create 2019-09-19 15:28
 **/
@Service
public class TestDelegateImp implements TestDelegate {
    private final static Logger logger = LoggerFactory.getLogger(TestDelegateImp .class);
    @Autowired
    ITestService testService;

    @Override
    public Result<String> index() {
        logger.info("index 我进来了");
        Result<String> result = new Result<String>();
        try {
            result.setData(testService.index());
            result.setCode(200);
        } catch (Exception e) {
            result.setCode(500);
            result.setMsg(e.getMessage());
        }
        IntStream.of(1,2,3).parallel().min().getAsInt();
        return result;
    }
}